package com.fangcun.controller.admin.old;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fangcun.bean.sys.PageBean;
import com.fangcun.bean.sys.ResponseMsg;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.util.PublicMethod;
import com.fangcun.common.util.apiversion.ApiVersion;
import com.fangcun.common.util.base.BaseAdminController;
import com.fangcun.entity.Teahouse;
import com.fangcun.service.admin.TeahouseService;

@RestController
@RequestMapping("/admin/{version}/auth/teahouse")
public class TeahouseController extends BaseAdminController{
	
	private static Logger LOG = LoggerFactory.getLogger(TeahouseController.class);
	
	@Autowired
	private TeahouseService teahouseService;
	
	/** 列表（也包含下拉） **/
	@ApiVersion(1.0)
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	private ResponseMsg list(@RequestBody PageBean<Teahouse> request) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			request.getParam().setId(getTeahouseId());
			msg.setData(teahouseService.list(request));
		} catch (ProException e) {
			LOG.error("-后台-茶楼列表->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("--后台-茶楼列表-->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
}
